package cn.lili.modules.promotion.entity.dto;

import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.StringUtils;
import cn.lili.modules.promotion.entity.enums.PromotionsApplyStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * 秒杀审核DTO
 */
@Data
public class SeckillAutidDTO {

    @ApiModelProperty(value = "审核状态")
    private PromotionsApplyStatusEnum promotionApplyStatus;// PASS

    @ApiModelProperty(value = "秒杀活动ID")
    private String seckillId;// 1697309561893089281

    @ApiModelProperty(value = "申请id集合")
    private List<String> ids;//: 1699992367292452866,1699992367296647169

    @ApiModelProperty(value = "审核失败原因")
    private String failReason;// 审核失败原因

    public void check() {
        if (ids == null || ids.isEmpty()) {
            throw new ServiceException("申请秒杀id不能为空");
        }
        if (CharSequenceUtil.isEmpty(seckillId)) {
            throw new ServiceException("秒杀活动ID不能为空");
        }

        if (promotionApplyStatus == null || promotionApplyStatus.equals(PromotionsApplyStatusEnum.APPLY)) {
            throw new ServiceException("审核状态不能为空");
        }
        if (promotionApplyStatus.equals(PromotionsApplyStatusEnum.REFUSE) && StringUtils.isEmpty(failReason)) {
            throw new ServiceException("审核失败原因不能为空");
        }
    }


}
